package com.gzist.elderlyserviceplatform.controller.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzist.elderlyserviceplatform.common.Result;
import com.gzist.elderlyserviceplatform.common.base.BaseDTO;
import com.gzist.elderlyserviceplatform.entity.po.NursingHome;
import com.gzist.elderlyserviceplatform.service.NursingHomeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 养老院信息表
 */
@RestController
@Tag(name = "养老院信息管理")
@RequestMapping("/api/client/nursingHome")
@RequiredArgsConstructor
public class NursingHomeControllerC {

    private final NursingHomeService nursingHomeService;

    @PostMapping("/list")
    @Operation(summary = "养老院查询列表获取")
    public Result<Page<NursingHome>> list(
            @RequestBody
            @Parameter(description = "分页参数") BaseDTO baseDTO
    ) {
        return Result.success(nursingHomeService.page(baseDTO));
    }

    @GetMapping("/detail/{id}")
    @Operation(summary = "单个养老院信息查询", description = "传递养老院id,根据id获取养老院信息")
    public Result<NursingHome> query(
            @PathVariable
            @Parameter(description = "养老院id") String id
    ) {
        return Result.success(nursingHomeService.getById(id), "查询成功");
    }
}